package com.kehao.accountbook.pojo;

import java.sql.Date;

public class SimpleDate {
    private int year;
    private int month;
    private int day;

    public static int getMonthDay(int year,int month){
        int monthday = 30;
        switch (month){
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                monthday = 31;
                break;
            case 2:
                if(year%4==0){
                    monthday = 29;
                }else {
                    monthday = 28;
                }
        }
        return monthday;
    }

    @Override
    public String toString() {
        String strMonth = (month<10?"0":"")+month;
        String strDay = (day<10?"0":"")+day;
        return year+"-"+strMonth+"-"+strDay;
    }

    public SimpleDate(int year, int month) {
        this.year = year;
        this.month = month;
    }

    public SimpleDate(int year, int month, int day) {
        this.year = year;
        this.month = month;
        this.day = day;
    }

    public SimpleDate() {
        Date date = new Date(System.currentTimeMillis());
        String str = date.toString();
        String[] strArr = str.split("-");
        year = Integer.parseInt(strArr[0]);
        month = Integer.parseInt(strArr[1]);
        day = Integer.parseInt(strArr[2]);
    }

    public SimpleDate(Date date){
        String str = date.toString();
        String[] strArr = str.split("-");
        year = Integer.parseInt(strArr[0]);
        month = Integer.parseInt(strArr[1]);
        day = Integer.parseInt(strArr[2]);
    }

    public SimpleDate(String str){
        if(!str.equals("")){
            String[] strArr = str.split("-");
            year = Integer.parseInt(strArr[0]);
            month = Integer.parseInt(strArr[1]);
            day = Integer.parseInt(strArr[2]);
        }else {
            year = 0;
        }
    }


    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public int getMonth() {
        return month;
    }

    public void setMonth(int month) {
        this.month = month;
    }

    public int getDay() {
        return day;
    }

    public void setDay(int day) {
        this.day = day;
    }
}
